<html><head><title>WaitThread</title></head>
<body bgcolor="#EFF1F0" link="#3A3966" vlink="#000000" alink="#000000">
<font face="Verdana, sans-serif" size="2"><p align="center"><b><font size="4">WaitThread()</font></b></p>
<p><b>Syntax</b></p><blockquote>
Result = <font color="#3A3966"><b>WaitThread</b></font>(Thread [, Timeout])</blockquote>

</blockquote>
<b>Description</b><br><blockquote>

Stop the program execution until the specified 'Thread' exits, or the optional timeout (in milliseconds) 
is reached. If the thread is already finished, it returns immediately. 

</blockquote><p><b>Parameters</b></p><blockquote>
<style type="text/css">
table.parameters { border-spacing: 0px; border-style: none; border-collapse: collapse; }
table.parameters td { border-width: 1px; padding: 6px; border-style: solid; border-color: gray; vertical-align: top; font-family:Arial; font-size:10pt; }
</style>
<table width="90%" class="parameters">
<tr><td width="10%"><i>Thread</i></td>
<td width="90%"> 
The thread to wait for. This value is returned by <a href="createthread.html">CreateThread()</a>. 

</td></tr>
<tr><td><i>Timeout (optional)</i></td>
<td> 
Timeout to wait, in milliseconds. 

</td></tr>
</table>
</blockquote><p><b>Return value</b></p><blockquote>

Nonzero if the thread has ended, or zero if the timeout was reached. 

</blockquote><p><b>Example</b></p><blockquote>

<pre><font face="Courier New, Courier, mono"size="2">  <b><font color="#3A3966">Procedure</font></b> <font color="#3A3966">PrintStuff</font>(*Interval)
    <b><font color="#3A3966">For</font></b> i = 0 <b><font color="#3A3966">To</font></b> 10
<font color="#3A3966">      PrintN</font>(&quot;.&quot;)
<font color="#3A3966">      Delay</font>(*Interval)
    <b><font color="#3A3966">Next</font></b>
  <b><font color="#3A3966">EndProcedure</font></b>
  
  <b><font color="#3A3966">If</font></b> <font color="#3A3966">OpenConsole</font>()
    thread =<font color="#3A3966"> CreateThread</font>(@PrintStuff(), 500)
    <b><font color="#3A3966">If</font></b> thread
      <font color="#3A3966">; Wait for thread to finish before we continue</font>
      <font color="#3A3966">; Try commenting the WaitThread function out and seeing what happens</font>
<font color="#3A3966">      WaitThread</font>(thread)
      
      <b><font color="#3A3966">For</font></b> i = 0 <b><font color="#3A3966">To</font></b> 10
<font color="#3A3966">        PrintN</font>(&quot;A&quot;)
<font color="#3A3966">        Delay</font>(1000)
      <b><font color="#3A3966">Next</font></b>
    <b><font color="#3A3966">EndIf</font></b>
  <b><font color="#3A3966">EndIf</font></b>
</font></pre>

</Blockquote><p><b>Supported OS </b><Blockquote>All</Blockquote></p><center><- <a href=waitsemaphore.html>WaitSemaphore()</a> - <a href="index.html">Thread Index</a><br><br>

</body></html>